import redis
from redis import StrictRedis

if __name__ == "__main__":
    try:
        # 链接redis数据库
        str = redis.Redis(host="172.22.206.143",port=6380,password="123456") #宿主的IP与映射的端口
        # 添加一个key
        res = str.set("icode","zhangyan")
        print(res)

        # 获取name的值
        #res = str.get("name")
        #print(res)

        # 删除name机器对应的值
        #res = str.delete("a5")

    except Exception as e:
        print(e)